<template>
  <van-popup position="right" v-model="isShow">
    <!-- <van-popup position="right"> -->
    <CompanyNavBar @leftClick="leftClick" title="职位详情">
      <template #left>
        <van-icon name="down" style="transform: rotate(90deg)" />
      </template>
      <template #right>
        <!-- <i class="iconfont iconxingxing2 i1"></i>
        <i class="iconfont iconbtn_share i2"></i> -->
      </template>
    </CompanyNavBar>
    <div class="header">
      <div class="top">
        <h3>{{ itemList.name }}</h3>
        <div class="price">{{ itemList.salary }}</div>
      </div>
      <div class="tags">
        <span class="tag">{{ itemList.city }}</span>
        <span class="tag">{{ itemList.experience }}</span>
        <span class="tag">{{ itemList.education }}</span>
      </div>
      <div class="welfare">
        <span
          v-for="(it, index) in itemList.feature"
          :key="index"
          class="item"
          >{{ it }}</span
        >
      </div>
    </div>
    <div class="content">
      <div class="positionInfo">
        <h3>职位描述</h3>
        <p>{{ itemList.responsibility }}</p>
      </div>
    </div>
    <div class="logo" @click="logoClick">
      <div class="img">
        <img :src="companyList.logo | formatImg" alt="" />
      </div>
      <div class="right">
        <div class="name">{{ companyList.name }}</div>
        <div class="tags">
          <span class="tag">{{ companyList.type }}</span>
          <span class="tag">{{ companyList.step }}</span>
          <span class="tag">{{ companyList.scale }}</span>
        </div>
      </div>
      <i class="iconfont iconicon_more"></i>
    </div>
    <van-button @click="questionClick">去刷题</van-button>
  </van-popup>
</template>

<script>
import { mapActions, mapState } from 'vuex'

export default {
  name: 'PositionDetail',
  props: {
    itemList: {
      type: Object,
      default: () => ({})
    }
  },
  data () {
    return {
      isShow: false,
      // 公司列表
      companyList: []
    }
  },
  async created () {
    // 调用获取公司列表详情
    await this.getDetailList(this.$route.query.id)
    this.companyList = this.detailList
    // console.log('this.companyList: ', this.companyList)
  },
  computed: {
    ...mapState('companyDetail', ['detailList'])
  },
  methods: {
    ...mapActions('companyDetail', ['getDetailList']),
    leftClick () {
      this.isShow = false
    },
    // logo跳转至公司详情
    logoClick () {
      this.$router.push('/companyDetail/' + this.$route.query.id)
      // console.log('this.$route: ', this.$route)
    },
    // 去刷题跳转
    questionClick () {
      // console.log('this.$route: ', this.$route)
      this.$router.push('/questions?companyId=' + this.$route.query.id)
    }
  }
}
</script>

<style lang="less" scoped>
.van-popup {
  padding: 0 30px 40px;
  width: 100%;
  height: 100%;
}
.header {
  box-shadow: 0px 4px 8px 0px rgba(24, 26, 57, 0.04);
  .top {
    margin-top: 35px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    h3 {
      height: 67px;
      font-family: PingFangSC-Semibold;
      font-size: 48px;
      color: #222222;
      letter-spacing: 0.55px;
      font-weight: 600;
    }
    .price {
      height: 45px;
      font-family: PingFangSC-Regular;
      font-size: 32px;
      color: #e40137;
      letter-spacing: 0.37px;
      text-align: right;
      font-weight: 400;
    }
  }
  .tags {
    margin-top: 38px;
    display: flex;
    justify-content: start;
    align-items: center;
    .tag {
      font-family: PingFangSC-Regular;
      font-size: 24px;
      color: #181a39;
      letter-spacing: 0.28px;
      font-weight: 400;
      margin-right: 35px;
    }
  }
  .welfare {
    padding: 30px 0 20px;
    .item {
      margin-right: 30px;
      font-family: PingFangSC-Regular;
      font-size: 24px;
      color: #b4b4bd;
      letter-spacing: 0.28px;
      font-weight: 400;
    }
  }
}
.positionInfo {
  h3 {
    padding: 48px 0 50px;
  }
}
.logo {
  margin-top: 50px;
  padding: 55px 30px;
  border: 2px solid #f7f4f5;
  border-left: 0;
  border-right: 0;
  display: flex;
  justify-content: space-around;
  align-items: center;
  .img {
    width: 115.74px;
    height: 115.17px;
    margin-right: 24px;
    overflow: hidden;
    border: 1px solid #f7f4f5;
    img {
      width: 100%;
      height: 100%;
    }
  }
  .right {
    .name {
      height: 40px;
      font-family: PingFangSC-Regular;
      font-size: 28px;
      color: #181a39;
      letter-spacing: 0.32px;
      font-weight: 400;
    }
    .tags {
      display: flex;
      justify-content: start;
      align-items: center;
      .tag {
        padding: 5px 10px;
        border: 1px solid #b4b4bd;
        border-radius: 6px;
        margin-right: 20px;
        font-family: PingFangSC-Regular;
        font-size: 24px;
        color: #545671;
        letter-spacing: 0.28px;
      }
    }
  }
}
::v-deep .van-button {
  width: 100%;
  height: 100px;
  background: #e40137;
  border-radius: 14px;
  font-family: PingFangSC-Regular;
  font-size: 32px;
  color: #ffffff;
  letter-spacing: 0.37px;
  text-align: center;
  font-weight: 400;
}
</style>
